<div class="form-add-demot-comment">
    <a href="#" class="auto-link" id="auto-link-add-demot">Dodaj komentarz</a>
    <div style="display:none;" id="form-add-demot">
        <form action="<?php echo View::getRoot(); ?>/index.php?controller=demot&action=save_comment" method="POST">
            Treść komentarza<br/>
            <input type="hidden" name="data[id_demot]" value="<?php echo $d['id'] ?>"/>
            <textarea name="data[content]" rows="4" cols="50"></textarea>
            <input type="hidden" name="data[token]" value="<?php echo View::get('comment_form_token'); ?>">
            <br/>
            <input type="submit" value="Zapisz">
        </form>
    </div>
</div>

<script type="text/javascript">
$(document).ready(function() 
{
    $('.auto-link').each(function() { 
        $name = this.id.substr(10);
        $('#form-'+$name)[0].orignHeight = $('#form-'+$name).css('height');
        $('#form-'+$name).css('height', '0px');
        console.log($('#form-'+$name)[0].orignHeight);
    });
    
    $('.auto-link').bind('click', function(e) {
       e.preventDefault();
       $name = this.id.substr(10);
       this.show=!this.show;
       if (this.show)
       {
           $('#form-'+$name).show().animate({'height': $('#form-'+$name)[0].orignHeight }, 500);
       }
       else
       {
           $('#form-'+$name).hide();
           $('#form-'+$name).css('height', '0px');
       }
       
    });
});
</script>
    